//
//  SDContentBaseViewController.m
//  SBooks
//
//  Created by shansander on 2016/11/12.
//  Copyright © 2016年 shansander. All rights reserved.
//

#import "SDContentBaseViewController.h"
#import "AppCustom.h"
#import "SDReadTitleLoadView.h"
@interface SDContentBaseViewController ()
{
    SDReadTitleLoadView * loadTitleView;
    BOOL isFirst;
}

@property (nonatomic, weak) IBOutlet UILabel * theErrorInfoLabel;

@end

@implementation SDContentBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString * dirctionpath = [AppCustom getSavedFileDirctionPath];
    NSString * path = [dirctionpath stringByAppendingPathComponent:self.fileName];
    self.theFilePath = path;
    
    __weak typeof(self) weak_self = self;
    loadTitleView = [[SDReadTitleLoadView alloc] initWithBackBlock:^(id sender) {
        [weak_self.navigationController popViewControllerAnimated:YES];
    } menuBlock:^(id sender) {
        [weak_self onSharedAction:sender];
    }];
    
    [self.view addSubview:loadTitleView];
    loadTitleView.title = self.fileName;
    
    self.automaticallyAdjustsScrollViewInsets = false;
    isFirst = true;
    
    self.theErrorInfoLabel.text = @"不支持该文件，请分享给其他文件使用";
    
    // Do any additional setup after loading the view.
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    if (isFirst) {
        [loadTitleView tapChangeTitleView];
        isFirst = false;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)onSharedAction:(id)sender{
    NSURL * url = [NSURL fileURLWithPath:self.theFilePath];
    
    UIActivityViewController * activity = [[UIActivityViewController alloc]
                                           initWithActivityItems:@[url]
                                           applicationActivities:[self getApplictionActivitys]];
    
    NSArray *cludeActivitys=@[];
    activity.excludedActivityTypes=cludeActivitys;
    [self presentViewController:activity animated:YES completion:^{
        
    }];
}

- (NSArray * )getApplictionActivitys
{
    return @[];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
